package com.linkai.controller.admin;

import com.linkai.enums.R;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

/**
 * @Author yamon
 * @Date 2021-04-02 14:11
 * @Description
 * @Version 1.0
 */
@Controller
@RequestMapping("/admin")
public class AdminIndexController {
    /**
     * 登录页面
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.GET)
    public ModelAndView loginPage(){
        final ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("admin/login_v2");
        return modelAndView;
    }

    /**
     * 登录
     * @param password
     * @return
     */
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    @ResponseBody
    public R loginByAdmin(@RequestParam String password){
        if (password==null){
            return R.error().data("error","输入密码为空！");
        }
        if (password.equals("Cym1437Qi.")){
            return R.ok().data("flag",true);
        }else{
            return R.error().data("error","输入密码错误！");
        }
    }
}
